public class SameTree {
    class Solution {
        public boolean isSymmetric(TreeNode root) {
            if(root==null){
                return true;
            }
            return isSymmetrichild(root.left,root.right);
        }


        public boolean isSymmetrichild(TreeNode rootleft,TreeNode rootright){
            if((rootleft==null && rootright != null)||(rootleft != null && rootright ==null)){
                return false;
            }
            if(rootleft==null && rootright==null){
                return true;
            }
            if(rootleft.val != rootright.val){
                return false;
            }
            return isSymmetrichild(rootleft.left,rootright.right) && isSymmetrichild(rootleft.right,rootright.left);
        }
    }
}
